package org.hxzon.workeasy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Size;

import org.hxzon.workeasy.model.base.BelongToUser;

@Entity
public class PostReply extends BelongToUser implements Comparable<PostReply> {

    private static final long serialVersionUID = -2394146567804248902L;

    @ManyToOne
    private EasyPost easyPost;

    @Column(columnDefinition = DefineVarchar64)
    @Size(max = DefineSize64)
    private String replyTitle;

    @Column(columnDefinition = DefineVarchar2048)
    @Size(max = DefineSize2048)
    private String replyContent;

    public String toString() {
        return this.replyTitle + "::(" + this.replyContent + ")";
    }

    public String print() {
        StringBuilder sb = new StringBuilder();
        sb.append("title:").append(replyTitle).append(",author:").append(this.getUsername());
        return sb.toString();
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof PostReply)) {
            return false;
        }
        PostReply other = (PostReply) o;
        return this.getId().equals(other.getId());
    }

    public int hashCode() {
        return this.getId().hashCode();
    }

    public int compareTo(PostReply o) {
        return this.replyTitle.compareTo(o.getReplyTitle());
    }

    public EasyPost getEasyPost() {
        return easyPost;
    }

    public void setEasyPost(EasyPost easyPost) {
        this.easyPost = easyPost;
    }

    public String getReplyTitle() {
        return replyTitle;
    }

    public void setReplyTitle(String replyTitle) {
        this.replyTitle = replyTitle;
    }

    public String getReplyContent() {
        return replyContent;
    }

    public void setReplyContent(String replyContent) {
        this.replyContent = replyContent;
    }

}
